using System.Collections.Generic;
using UnityEngine;

public class DialogDismissListener : MonoBehaviour
{
	private bool dismiss;

	private float startTime;

	private List<EventDelegate> onFinished = new List<EventDelegate>();

	public void SetOnFinished(EventDelegate del)
	{
		EventDelegate.Set(onFinished, del);
	}

	private void Awake()
	{
		dismiss = false;
	}

	private void OnEnable()
	{
		dismiss = false;
		GetComponent<UIWidget>().alpha = 1f;
	}

	public bool IsDismissing()
	{
		return dismiss;
	}

	public void Dismiss()
	{
		if (!dismiss)
		{
			dismiss = true;
			DialogTweener[] componentsInChildren = base.transform.GetComponentsInChildren<DialogTweener>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].Dismiss();
			}
			startTime = Time.realtimeSinceStartup;
		}
	}

	private void Update()
	{
		if (dismiss && Time.realtimeSinceStartup - startTime > 0.21f)
		{
			base.gameObject.SetActiveRecursively(state: false);
			EventDelegate.Execute(onFinished);
		}
	}
}
